home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
ezhint.exe
/
EZHINT.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-09
|
3KB
|
118 lines
#define Uses_TApplication
#define Uses_TStatusLine
#define Uses_TStatusDef
#define Uses_TStatusItem
#define Uses_TMenu
#define Uses_TMenuBar
#define Uses_TMenuItem
#define Uses_TSubMenu
#define Uses_TKeys
#define Uses_Strings
#include <tv.h>
#include "strings.h"
const cmAbout = 1000,
cmFileNew = 1001;
const hcSystem = 1000,
hcAbout = 1001,
hcFile = 1002,
hcFileExit = 1003,
hcFileNew = 1004;
static StrRef strRef[] = {
{ hcSystem, "system commands" },
{ hcAbout, "show version and copyright information" },
{ hcFile, "file-management commands (Open, Save, etc)" },
{ hcFileExit, "exit the program" },
{ hcFileNew, "create a new file in a new Edit window" },
{ srNull, 0 }
};
class THintStatusLine : public TStatusLine
{
public:
THintStatusLine( const TRect& bounds, TStatusDef& aDefs ) :
TStatusLine( bounds, aDefs )
{
s.load(strRef);
};
virtual const char* hint( ushort aHelpCtx );
protected:
Strings s;
};
const char* THintStatusLine::hint( ushort aHelpCtx )
{
char *p = s[aHelpCtx];
if( p == 0 )
return TStatusLine::hint(aHelpCtx);
else
return p;
}
class TApp : public TApplication
{
public:
TApp() : TProgInit(initStatusLine, initMenuBar, initDeskTop)
{}
static TMenuBar *initMenuBar( TRect );
static TStatusLine *initStatusLine( TRect );
};
TMenuBar *TApp::initMenuBar( TRect r )
{
r.b.y = r.a.y+1;
TSubMenu& sub1 = *new TSubMenu( "~≡~", kbAltSpace, hcSystem ) +
*new TMenuItem( "~A~bout...", cmAbout, 0, hcAbout, 0, 0 );
TSubMenu& sub2 = *new TSubMenu( "~F~ile", kbNoKey, hcFile ) +
*new TMenuItem( "~N~ew", cmFileNew, kbNoKey, hcFileNew, 0 )+
newLine() +
*new TMenuItem( "E~x~it", cmQuit, kbAltX, hcFileExit, "Alt-X" );
TMenuBar *menuBar = new TMenuBar( r, new TMenu((TMenuItem &) (
sub1 + sub2)));
return menuBar;
}
TStatusLine *TApp::initStatusLine( TRect r )
{
r.a.y = r.b.y-1;
return new THintStatusLine( r,
*new TStatusDef( hcSystem, hcFileNew )+
*new TStatusItem( "~F1~ Help", kbF1, cmHelp )+
*new TStatusItem( 0, kbAltX, cmQuit )+
*new TStatusItem( 0, kbAltF3, cmClose )+
*new TStatusItem( 0, kbF5, cmZoom )+
*new TStatusItem( 0, kbCtrlF5, cmResize )+
*new TStatusItem( 0, kbF10, cmMenu )+
*new TStatusDef( 0, 0xFFFF )+
*new TStatusItem( "~F1~ Help", kbF1, cmHelp )+
*new TStatusItem( "~Alt-X~ Exit", kbAltX, cmQuit )+
*new TStatusItem( 0, kbAltF3, cmClose )+
*new TStatusItem( 0, kbF5, cmZoom )+
*new TStatusItem( 0, kbCtrlF5, cmResize )+
*new TStatusItem( 0, kbF10, cmMenu )
);
}
int main()
{
TApp app;
app.run();
app.shutDown();
return 0;
}